@extends('home.base.index')
@section('content')
    <!--内容开始-->
    <div class="personal w1200">
    	<div class="personal-left f-l">
        	<div class="personal-l-tit">
            	<h3>个人中心</h3>
            </div>
            <ul>
            	   <li class="current-li per-li1"><a href="#">消息中心<span>></span></a></li>
                <li class="per-li2"><a href="{{url('/home/userinfo')}}">个人资料<span>></span></a></li>
                <li class="per-li3"><a href="/home/userorder">我的订单<span>></span></a></li>
                <li class="per-li6"><a href="/home/address">管理收货地址<span>></span></a></li>
                <li class="per-li7"><a href="/home/interest">商品收藏<span></span></a></li>
                <li class="per-li8"><a href="/home/okconfirm">确认收货<span>></span></a></li>
                <li class="per-li9"><a href="#">浏览记录<span>></span></a></li>
                <li class="per-li10"><a href="#">会员积分<span>></span></a></li>
            </ul>
        </div>
    	<div class="order-right f-r">
        	<div class="order-hd">
            	<dl class="f-l">
                	<dt>
                    	<a href="#"><img src="images/data-tu2.gif" /></a>
                    </dt>
                    <dd>
                    	<h3><a href="#">RH了</a></h3>
                        <p>zhao601884596</p>
                    </dd>
                    <div style="clear:both;"></div>
                </dl>
                <div class="ord-dai f-l">
                	<p>待付款<span>1</span></p>
                	<p>待发货<span>1</span></p>
                	<p>待收货<span>1</span></p>
                	<p>待评价<span>1</span></p>
                </div>
                <div style="clear:both;"></div>
            </div>
            <div class="order-md">
            	<div class="md-tit">
                	<h3>我的订单</h3>
                </div>
                <div class="md-hd">
                	<P class="md-p1"><input type="checkbox" name="hobby" value=""></input><span>全选</span></P>
                    <p class="md-p2">商品信息</p>
                    <p class="md-p4">单价（元）</p>
                    <p class="md-p5">金额（元）</p>
                    <p class="md-p6">操作</p>
                </div>
                <form method="post" name="userorder" action="{{ url('/home/userorder') }}">
                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                    <input type="hidden" name="_method" value="DELETE">
                </form>
                <div class="md-info">
                	<div class="dai">
                    	<input type="checkbox" name="hobby" value=""></input><span>待付款</span>
                    </div>
                   @foreach($list as $v)
                    @if($v->status==1)
                    <div class="dai-con">
                        <dl class="dl1">
                            <dt>
                                <input type="checkbox" name="hobby" value="" class="f-l"></input>
                                <a href="#" class="f-l"><img src="{{ asset('images') }}/{{ $v->picture }}" width="80px" /></a>
                                <div style="clear:both;"></div>
                            </dt>
                            <dd>
                                <p>{{ $v->description }}</p>
                                <span>X {{ $v->product_num }}</span>
                            </dd>
                            <div style="clear:both;"></div>
                        </dl>
                        <div class="dai-right f-l">
                            <p class="d-r-p2">{{ $v->lower_price }}￥</p>
                            <p class="d-r-p3">{{ $v->total_price }}</p>
                            <p class="d-r-p4" style="margin-top:20px;" id="{{ $v->id }}"><a href="javascript:void(0);" onclick="doInterest({{ $v->id }})">移入收藏夹</a><br /><a href="/car/pay/{{ $v->id }}/edit">去付款</a><br><a href="javascript:doDel({{ $v->id }})">删除</a></p>
                        </div>
                        <div style="clear:both;"></div>
                    </div>
                    @endif
                    @endforeach
                </div>
                <div class="md-info">
                	<div class="dai">
                    	<input type="checkbox" name="hobby" value=""></input><span>待发货</span>
                    </div>
                    @foreach($list as $v)
                    @if($v->status==2)
                    <div class="dai-con">
                    	<dl class="dl1">
                        	<dt>
                                <input type="checkbox" name="hobby" value="" class="f-l"></input>
                                <a href="#" class="f-l"><img src="{{ asset('images') }}/{{ $v->picture }}" width="80px" /></a>
                                <div style="clear:both;"></div>
                            </dt>
                            <dd>
                            	<p>{{ $v->description }}</p>
                                <span>X {{ $v->product_num }}</span>
                            </dd>
                            <div style="clear:both;"></div>
                        </dl>
                        <div class="dai-right f-l">
                            <p class="d-r-p2">{{ $v->lower_price }}￥</p>
                            <p class="d-r-p3">{{ $v->total_price }}</p>
                            <p class="d-r-p4" style="margin-top:20px;" id="{{ $v->id }}"><a href="javascript:void(0);" onclick="doInterest({{ $v->id }})">移入收藏夹</a><br /><a href="javascript:doDel({{ $v->id }})">删除</a></p>
                        </div>
                        <div style="clear:both;"></div>
                    </div>
                    @endif
                    @endforeach
                </div>
                <div class="md-info">
                	<div class="dai">
                    	<input type="checkbox" name="hobby" value=""></input><span>待收货</span>
                    </div>
                    @foreach($list as $v)
                    @if($v->status==3)
                    <div class="dai-con">
                        <dl class="dl1">
                            <dt>
                                <input type="checkbox" name="hobby" value="" class="f-l"></input>
                                <a href="#" class="f-l"><img src="{{ asset('images') }}/{{ $v->picture }}" width="80px"/></a>
                                <div style="clear:both;"></div>
                            </dt>
                            <dd>
                                <p>{{ $v->description }}</p>
                                <span>X {{ $v->product_num }}</span>
                            </dd>
                            <div style="clear:both;"></div>
                        </dl>
                        <div class="dai-right f-l">
                            <p class="d-r-p2">{{ $v->lower_price }}￥</p>
                            <p class="d-r-p3">{{ $v->total_price }}</p>
                            <p class="d-r-p4" style="margin-top:20px;" id="{{ $v->id }}"><a href="javascript:void(0);" onclick="doInterest({{ $v->id }})">移入收藏夹</a><br /><a href="{{ url('home/okconfirm') }}">确认收货</a><br /><a href="JavaScript:;" ckwl="">查看物流</a></p>
                        </div>
                        <div style="clear:both;"></div>
                    </div>
                    @endif
                    @endforeach
                </div>
                <div class="md-info">
                    <div class="dai">
                        <input type="checkbox" name="hobby" value=""></input><span>待评价</span>
                    </div>
                    @foreach($list as $v)
                    @if($v->status==4)
                    <div class="dai-con">
                        <dl class="dl1">
                            <dt>
                                <input type="checkbox" name="hobby" value="" class="f-l"></input>
                                <a href="#" class="f-l"><img src="{{ asset('images') }}/{{ $v->picture }}" width="80px"/></a>
                                <div style="clear:both;"></div>
                            </dt>
                            <dd>
                                <p>{{ $v->description }}</p>
                                <span>X {{ $v->product_num }}</span>
                            </dd>
                            <div style="clear:both;"></div>
                        </dl>
                        <div class="dai-right f-l">
                            <p class="d-r-p2">{{ $v->lower_price }}￥</p>
                            <p class="d-r-p3">{{ $v->total_price }}</p>
                            <p class="d-r-p4" style="margin-top:20px;" id="{{ $v->id }}" ><a  href="javascript:void(0);" onclick="doInterest({{ $v->id }})">移入收藏夹</a><br><a b="a" onclick="doEval(this,{{ $v->id }})" href="javascript:void(0);">去评价</a></p>
                        </div>
                        <div style="clear:both;"></div>
                    </div>
                    @endif
                    @endforeach
                </div>
                <!--分页-->
                <div class="paging">
            	   {{ $list->appends($where)->links() }}
                </div>
                <br><br>
                <div class="md-ft">
                	<P class="md-p1"><input type="checkbox" name="hobby" value=""></input><span>全选</span></P>
                    <a href="#">删除</a>
                    <a href="#">加入收藏夹<span>（此处始终在屏幕下方）</span></a>
                    <button>结算</button>
                </div>
            </div>
            
        </div>
        <div style="clear:both;"></div>
    </div>
    <script type="text/javascript">
        alert("数据提交中...");
        function doDel(id)
        {
             if(confirm('确定要删除吗？')){
                var form = document.userorder;
                form.action = '/home/userorder/'+id;
                form.submit();
            }
        }
        
       console.log($('#22').children().html());
        var product_id = '';
        var status = '';
        @foreach ($list as $v)
            product_id += {{ $v->product_id }}+',';
            status += {{ $v->status }}+',';
        @endforeach
        //console.log($("#22"));
        var url = "{{ url('home/aja/interest') }}";
        $.ajax({
            url:url,
            async:false,                //是否异步
            type:'get',                 //请求方式
            data:{product_id:product_id,status:status},              //发送的数据
            dataType:'json',            //响应的数据类型
            error:function()            //失败时回调函数
            {
                alert('ajax请求失败');
            },
            success:function(data)      //成功时回调函数
            {
                var id = data.split(',');
                id.pop();
               for(i=0;i<id.length;i++){
                    $('#'+id).children().first().attr('onclick','');
                    $('#'+id[i]).children().first().html('已加入收藏');
                }
                
            }
        });

        function doInterest(id){
            var url = "{{ url('home/aja/dointerest') }}";
            //console.log(id);
            $.ajax({
            url:url,
            async:false,                //是否异步
            type:'get',                 //请求方式
            data:{id:id},              //发送的数据
            dataType:'json',            //响应的数据类型
            error:function()            //失败时回调函数
            {
                alert('ajax请求失败');
            },
            success:function(data)      //成功时回调函数
            {
                if(data==1){
                    $('#'+id).children().first().html('已加入收藏');
                    $('#'+id).children().first().attr('onclick','');
                    
                }
                
                
            }
        });
        }
        function doEval(ob,id){
            var url = "{{ url('home/aja/doEval') }}";
             $.ajax({
            url:url,
            async:false,                //是否异步
            type:'get',                 //请求方式
            data:{id:id},              //发送的数据
            dataType:'json',            //响应的数据类型
            error:function()            //失败时回调函数
            {
                alert('ajax请求失败');
            },
            success:function(data)      //成功时回调函数
            {
                
                if(data==1){
                    ob.href='/home/eval/'+id;
                }
                if(data==2){
                    alert("用户已经评价过了");
                }
                
            }
        });
           
        }
        $('.pagination').find('li').css({"font-size":"23px","background":"#63a61d none repeat scroll 0 0","height": "35px","line-height":"35px","width": "41px","float":"left"});
    </script>
    
    <!--底部一块-->
   @stop